
# 基础镜像阶段
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080

# 构建阶段
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["MCPSSETest/MCPSSETest.csproj", "MCPSSETest/"]
RUN dotnet restore "./MCPSSETest/MCPSSETest.csproj"
COPY . .
WORKDIR "/src/MCPSSETest"
RUN dotnet build "./MCPSSETest.csproj" -c $BUILD_CONFIGURATION -o /app/build

# 发布阶段
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./MCPSSETest.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

# 最终阶段
FROM base AS final
WORKDIR /app


COPY  /ms-playwright /ms-playwright


# 复制应用程序
COPY --from=publish /app/publish .

# 设置环境变量，优化 Playwright 运行
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1

ENTRYPOINT ["dotnet", "MCPSSETest.dll"]